﻿#pragma once
#include "TinyEngine\\T_Engine.h"
#include "TinyEngine\\T_Scene.h"
#include "TinyEngine\\T_Sprite.h"
#include "TinyEngine\\T_Menu.h"
#include "TinyEngine\\T_AI.h"
#include "TinyEngine\\T_Audio.h"
typedef vector<T_Sprite*>vSpriteSet;
class CrazyArcade :public T_Engine
{
private:
	// 帧序列
	static const int TOTALFRAMES = 18;
	static int FRAME_LEFT[TOTALFRAMES];
	static int FRAME_RIGHT[TOTALFRAMES];
	static int FRAME_UP[TOTALFRAMES];
	static int FRAME_DOWN[TOTALFRAMES];
	// 炸弹的帧序列
	static const int TOTALFRAME_BOMB = 18;
	static int FRAME_BOMB[TOTALFRAME_BOMB];
	// explosion的帧序列
	static const int one = 1;
	static int FRAME_EXP_UP0[1];
	static int FRAME_EXP_UP1[1];
	static int FRAME_EXP_DOWN0[2];
	static int FRAME_EXP_DOWN1[1];
	static int FRAME_EXP_LEFT0[2];
	static int FRAME_EXP_LEFT1[1];
	static int FRAME_EXP_RIGHT0[2];
	static int FRAME_EXP_RIGHT1[1];

	static const int NPC_NUM = 10;
//	static int sequence[TOTALFRAMES];
	// AI类
	T_AI* t_ai;
	// 游戏场景
	T_Scene t_Scene; 

	// bomb水泡/炸弹
	vSpriteSet bombs_set;
	// explosion 爆炸效果
	vSpriteSet explosion_up_set;
	vSpriteSet explosion_down_set;
	vSpriteSet explosion_left_set;
	vSpriteSet explosion_right_set;

	//屏幕与窗口宽高
	int scn_width, scn_height;
	int wnd_width, wnd_height;

	// 游戏角色
	T_Sprite *player;
	// 角色被炸到的Graph指针
	T_Graph* pPlayerExdGraph;
	// NPC被炸到的Graph指针
	T_Graph* pNPCExdGraph;

	// 游戏界面
	T_Graph* t_graph_win;
	T_Graph* t_graph_lost;
	
	//声音控制
	AudioDX ds;
	AudioDXBuffer backmusic_buffer;
	AudioDXBuffer robot_buffer;
	AudioDXBuffer mousedown_buffer;
	AudioDXBuffer mousemove_buffer;


	vSpriteSet npc_set;

	// 游戏菜单
	T_Menu t_menu;
	T_Menu t_menu_select;
	T_Menu t_menu_about;
	// 加载游戏菜单
	void LoadMenu();
	// 加载地图
	void LoadMap();
	// 加载玩家角色
	void LoadPlayer();
	// 加载NPC角色
	void LoadNpc(int total);
	// 加载炸弹/水泡
	void LoadBombs(int total);
	// 加载爆炸效果
	void LoadExplosion(int total);
	// 更新玩家角色位置
	void UpdatePlayerPos(int dir);
	// 更新NPC角色位置
	void UpdateNpcPos();
	// 更新explosion的位置
	void UpdataExpPos(T_Sprite* exp,int dir);
	// 更新动画
	void UpdateAnimation();
public:
	virtual ~CrazyArcade(void);
	CrazyArcade(HINSTANCE h_instance, LPCTSTR sz_winclass, LPCTSTR sz_title,
		WORD icon = NULL, WORD sm_icon = NULL,
		int winwidth = 800, int winheight = 600);
	void GameInit();
	void GameLogic();
	void GameEnd();
	void GamePaint(HDC hdc);
	void GameKeyAction(int Action = KEY_SYS_NONE);
	void GameMouseAction(int x, int y, int Action);
};